/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbbeans;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Laur
 */
@Entity
@Table(name = "trees", catalog = "wad", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Trees.findAll", query = "SELECT t FROM Trees t"), // NQ used to select all the trees
    @NamedQuery(name = "Trees.findById", query = "SELECT t FROM Trees t WHERE t.id = :id"), // NQ used to select a tree by id
    @NamedQuery(name = "Trees.findByName", query = "SELECT t FROM Trees t WHERE t.name = :name"), // NQ used to select trees by their name
    @NamedQuery(name = "Trees.findByUser", query = "SELECT t FROM Trees t WHERE t.user = :user")}) // NQ used to select trees of a user
public class Trees implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name", nullable = false, length = 50)
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "user", nullable = false)
    private int user;
    
    // constructors used to instantiate this bean
    public Trees() {
    }

    public Trees(Integer id) {
        this.id = id;
    }

    public Trees(Integer id, String name, int user) {
        this.id = id;
        this.name = name;
        this.user = user;
    }
    public Trees(String name, int user){
        this.name=name;
        this.user=user;
    }

    // getters and setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getUser() {
        return user;
    }

    public void setUser(int user) {
        this.user = user;
    }

    // hashCode() and equals()
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Trees)) {
            return false;
        }
        Trees other = (Trees) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dbbeans.Trees[ id=" + id + " ]";
    }
    
}
